package com.taoz.rpc.core.loadbalancer;

import com.taoz.rpc.core.config.ApplicationConfig;
import com.taoz.rpc.core.spi.SpiLoader;

public class LoadBalancerFactory {
    static {
        SpiLoader.load(LoadBalancer.class);
    }

    public static LoadBalancer getLoadBalancer(String className) throws InstantiationException, IllegalAccessException {
        return (LoadBalancer) SpiLoader.getInstance(className);
    }

    public static LoadBalancer getLoadBalancer() throws InstantiationException, IllegalAccessException {
        String className = ApplicationConfig.getConfig().getLoadBalancer();
        return (LoadBalancer) SpiLoader.getInstance(className);
    }
}
